{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加广告位</h5>
                </div>
                <div class="ibox-content">
                    <form class="layui-form layui-form-pane" action="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">名称：</label>
                            <div class="layui-input-inline">
                                <input id="name" type="text" class="layui-input" lay-verify="required" lay-verType="tips" name="name">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">排&nbsp;&nbsp;序：</label>
                            <div class="layui-input-inline">
                                <input id="orderby" type="number" class="layui-input" name="orderby" lay-verify="required|number" min="0" lay-verType="tips" value="10">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">状&nbsp;态：</label>
                            <div class="layui-input-block">
                                <input type="radio" name='status' value="1" checked="checked" title="开启"/>&nbsp;&nbsp;
                                <input type="radio" name='status' value="0" title="关闭"/>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="btn btn-primary" type="submit" lay-submit lay-filter="add_position"><i
                                        class="fa fa-save"></i> 保存
                                </button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i>
                                    返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    var form = layui.form;
    $(function () {
        form.on('submit(add_position)', function (data) {
            var data = data.field;
            $.post("{:url('add_position')}", data, function (result) {
                if (result.code == 1) {
                    layer.msg(result.msg, {icon: 6, time: 1500, shade: 0.1}, function () {
                        window.location.href = "{:url('ad/index_position')}";
                    });
                } else {
                    layer.msg(result.msg, {icon: 5, time: 1500, shade: 0.1});
                    return false;
                }
            });
            return false;
        });

    });

</script>
</body>
</html>